<!DOCTYPE html>
<html>

<head>

    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta name="csrf-token" content="{{ csrf_token() }}">
    <title>修改账号密码</title>
    <link rel="shortcut icon" href="favicon.ico">
    <link href="{{laracvs_asset('admin/css/bootstrap.min.css?v=3.3.6')}}" rel="stylesheet">
    <link href="{{laracvs_asset('admin/css/font-awesome.css?v=4.4.0')}}" rel="stylesheet">
    <link href="{{laracvs_asset('admin/css/plugins/iCheck/custom.css')}}" rel="stylesheet">
    <link href="{{laracvs_asset('admin/css/animate.css')}}" rel="stylesheet">
    <link href="{{laracvs_asset('admin/css/style.css?v=4.1.0')}}" rel="stylesheet">

</head>

<body class="gray-bg">
<div class="wrapper wrapper-content animated fadeInRight">
    <div class="row">
        <div class="col-sm-12">
            <div class="ibox float-e-margins">
                <div class="ibox-title">
                    <h5>修改账号密码</h5>
                    <div class="ibox-tools">
                        <a class="collapse-link">
                            <i class="fa fa-chevron-up"></i>
                        </a>
                    </div>
                </div>
                <form id="logout-form" action="{{ route('logout') }}" method="POST" style="display: none;">
                    {{ csrf_field() }}
                </form>
                <div class="ibox-content">
                    <form class="form-horizontal" id="myform">
                        <div class="form-group">
                            <label class="col-sm-2 control-label">管理员名称</label>

                            <div class="col-sm-10">
                                <input type="text" placeholder="请输入管理员名称" name="name" value="{{ Auth::user()->name }}" class="form-control">
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label">管理员密码</label>

                            <div class="col-sm-10">
                                <input type="text" placeholder="请输入管理员密码" name="password" class="form-control">
                            </div>
                        </div>
                        <div class="form-group">
                            <div class="col-sm-4 col-sm-offset-2">
                                <div class="btn btn-primary" type="submit" id="submit">修改</div>
                            </div>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
</div>
<!-- 全局js -->
<script src="{{laracvs_asset('admin/js/jquery.min.js?v=2.1.4')}}"></script>
<script src="{{laracvs_asset('admin/js/bootstrap.min.js?v=3.3.6')}}"></script>

<!-- 自定义js -->
<script src="{{laracvs_asset('admin/js/plugins/layer/layer.min.js')}}"></script>
<script src="{{laracvs_asset('admin/js/content.js?v=1.0.0')}}"></script>

<!-- iCheck -->
<script>
    $(function () {
        $('#submit').click(function () {
            var name = $('[name="name"]').val();
            var password = $('[name="password"]').val();
            if (name == ""||password=="") {
                layer.msg('请填写完整信息')
                return false;
            }
            var fm = new FormData($('#myform')[0])
            $.ajax({
                type: "post",
                url: "/action/changeinfo",
                dataType: "json",
                data: fm,
                headers: {
                    'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content'),
                },
                processData: false,
                contentType: false,
                error: function (data){
                    layer.msg("失败")
                },
                success: function (resp) {
                    if (resp.status == 200) {
                        layer.msg(resp.msg);
                        $('#logout-form').submit();
                    } else {
                        layer.msg(resp.msg)
                    }
                }
            })
        })
    })
</script>

</body>

</html>
